blob: fdead9fbf3fdcce4fc2e35862ffd56fc038c15c1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
'use client';
import { Column, Row } from '@umami/react-zen';
import { useState } from 'react';
import { FieldSelectForm } from '@/app/(main)/websites/[websiteId]/(reports)/breakdown/FieldSelectForm';
import { WebsiteControls } from '@/app/(main)/websites/[websiteId]/WebsiteControls';
import { Panel } from '@/components/common/Panel';
import { useDateRange, useMessages } from '@/components/hooks';
import { ListCheck } from '@/components/icons';
import { DialogButton } from '@/components/input/DialogButton';
import { Breakdown } from './Breakdown';
export function BreakdownPage({ websiteId }: { websiteId: string }) {
const {
dateRange: { startDate, endDate },
} = useDateRange();
const [fields, setFields] = useState(['path']);
return (
<Column gap>
<WebsiteControls websiteId={websiteId} />
<Row alignItems="center" justifyContent="flex-start">
<FieldsButton value={fields} onChange={setFields} />
</Row>
<Panel height="900px" overflow="auto" allowFullscreen>
<Breakdown
websiteId={websiteId}
startDate={startDate}
endDate={endDate}
selectedFields={fields}
/>
</Panel>
</Column>
);
}
const FieldsButton = ({ value, onChange }) => {
const { formatMessage, labels } = useMessages();
return (
<DialogButton
icon={<ListCheck />}
label={formatMessage(labels.fields)}
width="400px"
minHeight="300px"
variant="outline"
>
{({ close }) => {
return <FieldSelectForm selectedFields={value} onChange={onChange} onClose={close} />;
}}
</DialogButton>
);
};
|